<?php include_once '../config/dbconfig.php'; ?>
<?php include_once 'comment.class.php'; ?>

<?

    $comment=new comment();

    switch ($_REQUEST['action']){
        
        case "newComment":
            
            $comment->user_id=$_REQUEST['user_id'];
            $comment->challenge_id=$_REQUEST['challenge_id'];
            $comment->comment=$_REQUEST['newComment'];
            
            if($comment->addComment()){
                
                echo "works";
                
            }
            
            break;
        
        case "deleteComment":
            
            break;
        
        case "loadCommentsForChallenge":
            
            
            
           echo json_encode($comment->loadAllCommentForChallenge($_REQUEST['challenge_id']));
            
            break;
        
    }

?>
